<?php
/**
 * 
 * Контроллер пользователей
 * @author andrew
 *
 */
class Users_IndexController extends Zend_Controller_Action {

	/**
	 * Страница пользователя
	 */
	public function indexAction() {
		$auth = Zend_Auth::getInstance();
		
		$user_id = $auth->getIdentity()->id;
		
		$user = Doctrine_Core::getTable('Users_Model_Users')->find($user_id);
		
		if($user->first_name && $user->last_name) {
			$this->view->fullname = $user->first_name . ' ' . $user->last_name;
		} else {
			$this->view->fullname = $user->username;
		}
		
		$this->view->user =  $user;
                
	}
	
	/**
	 * Отправка сообщения пользователю
	 */
	public function sendmessageAction() {
		$auth = Zend_Auth::getInstance();
		
		$alias = $this->_request->getParam('alias',0);
		
		$user = Doctrine_Core::getTable('Users_Model_Users')->findByUsername($alias);
		
		if(!$alias || !$user) {
			throw new Zend_Controller_Action_Exception($this->view->translate('Пользователь не найден'), 404);
		}
		if($user[0]->id == $auth->getIdentity()->id) {
			return $this->_redirect($this->view->url(array(),'users_index_index'));
		}
		
		//находим переписку
		$dialog = Doctrine_Query::create()
				  ->from('Users_Model_Message')
				  ->where('from_id = ?', $auth->getIdentity()->id)
				  ->andWhere('to_id = ?', $user[0]->id)
				  ->orWhere('from_id = ?', $user[0]->id)
				  ->andWhere('to_id = ?', $auth->getIdentity()->id)
				  ->orderBy('created_at')
				  ->execute();				  
		
		
		$form = new Users_Form_Message();
		$form->setAction($this->view->url(array('alias' => $alias),'users_index_sendmessage'));
		
		if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
			$values = $form->getValues();
			
			$message = new Users_Model_Message();
			$message->from_id = $auth->getIdentity()->id;
			$message->to_id = $user[0]->id;
			$message->created_at = time();
			$message->message = $values['message'];
			$message->save();
			$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Сообщение успешно отправлено!'));
				 
			return $this->_redirect($this->view->url(array(),'users_index_index'));
		}
		
		$this->view->dialog = $dialog;
		$this->view->form = $form;
		$this->view->user = $user[0];
	}
	
	/**
	 * Диалоги
	 */
	public function dialogsAction() {
		
	} 
	
	/**
	 * Просмотр страницы другого пользователя
	 */
	public function userAction() {
		$auth = Zend_Auth::getInstance();
		
		$alias = $this->_request->getParam('alias',0);
		
		$user = Doctrine_Core::getTable('Users_Model_Users')->findByUsername($alias);
		
		if(!$alias || !$user) {
			throw new Zend_Controller_Action_Exception($this->view->translate('Пользователь не найден'), 404);
		}
		if($user[0]->id == $auth->getIdentity()->id) {
			return $this->_redirect($this->view->url(array(),'users_index_index'));
		}
		$this->view->user = $user[0];
	}
	
	/**
	 * Изменение настроек
	 */
	public function profileAction() {
		$auth = Zend_Auth::getInstance();
		
		$user_id = $auth->getIdentity()->id;
		
		$user = Doctrine_Core::getTable('Users_Model_Users')->find($user_id);
		
		$populate = array(
			'username' => $user->username,
			'first_name' => $user->first_name,
			'last_name' => $user->last_name,
			'email' => $user->email,
			'show_email' => $user->Profile_Users_Alias->show_email,
			'show_birthday' => $user->Profile_Users_Alias->show_birthday,
			'show_me' => $user->Profile_Users_Alias->show_me,
			'birthday' => $user->Profile_Users_Alias->birthday,
			'about' => $user->Profile_Users_Alias->about,
			'sex' => $user->Profile_Users_Alias->sex
		);
		
		$form = new Users_Form_Profile();
		$form->setAction($this->view->url(array(),'users_index_profile'));
		
		$form_pwd = new Users_Form_Changepwd();
		$form_pwd->setAction($this->view->url(array(),'users_index_changepwd'));
		
		$username = $form->getElement('username');
		$username->addValidator(new ZFEngine_Validate_Doctrine_NoRecordExist('Users_Model_Users','username', $user->username),true);
		$email = $form->getElement('email');
		$email->addValidator(new ZFEngine_Validate_Doctrine_NoRecordExist('Users_Model_Users','email', $user->email),true);
		
		$this->view->form = $form;
		$this->view->form_pwd = $form_pwd;
		
		if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
			$values = $form->getValues();
			
			$user->username = $values['username'];
			$user->email = $values['email'];
			$user->first_name = $values['first_name'];
			$user->last_name = $values['last_name'];
			$user->Profile_Users_Alias->show_email = $values['show_email'];
			$user->Profile_Users_Alias->show_birthday = $values['show_birthday'];
			$user->Profile_Users_Alias->birthday = $values['birthday'];
			$user->Profile_Users_Alias->about = $values['about'];
			$user->Profile_Users_Alias->sex = $values['sex'];
			$user->Profile_Users_Alias->show_me = $values['show_me'];
			$user->save();
			$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Информация о вас успешно сохранена!'));
				 
			return $this->_redirect($this->view->url(array(),'users_index_index'));
		} else {
			$form->populate($populate);
		}
	}
	/**
	 * 
	 * Изменение фотографии пользователя
	 */
	public function photoAction() {
		$auth = Zend_Auth::getInstance();
		
		$form = new Users_Form_Photo();
		$form->setAction($this->view->url(array(),'users_index_photo'));
		
		if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
			
			$file = $form->photo->getFileInfo();
			
			if($file['photo']['error'] == 0) {
				
				$user = Doctrine_Core::getTable('Users_Model_Users')->find($auth->getIdentity()->id);
				
				if($user->localphoto) {
					unlink(APPLICATION_PATH . "/../upload/media/pictures/avatars/original/" . $user->localphoto);
					unlink(APPLICATION_PATH . "/../upload/media/pictures/avatars/medium/" . $user->localphoto);
					unlink(APPLICATION_PATH . "/../upload/media/pictures/avatars/small/" . $user->localphoto);
				}
				
				$ext = split("[/\\.]", $file['photo']['name']);
				$newName =  $auth->getIdentity()->username . '_' . md5(time()) . '.' . $ext[count($ext)-1];
				
				$factoryImage = ZFEngine_Image::factory(APPLICATION_PATH . "/../upload/media/pictures/avatars/original/" . $file['photo']['name']);
				$factoryImage->saveAs(APPLICATION_PATH . "/../upload/media/pictures/avatars/original/" . $newName, 90);
				$factoryImage->resize(180, 0, true);
				$factoryImage->saveAs(APPLICATION_PATH . "/../upload/media/pictures/avatars/medium/" . $newName, 90);
				$factoryImage->resize(64, 0, true);
				$factoryImage->saveAs(APPLICATION_PATH . "/../upload/media/pictures/avatars/small/" . $newName, 90);
				$form->photo->receive();
				
				unlink(APPLICATION_PATH . "/../upload/media/pictures/avatars/original/" . $file['photo']['name']);
				
				
				$user->localphoto = $newName;
				$user->save();
				
				$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Основное фото успешно изменено!'));
				 
				return $this->_redirect($this->view->url(array(),'users_index_index'));
				
			} else {
				$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Ошибка при передаче файла! Попробуйте еще раз!'));
				 
				return $this->_redirect($this->view->url(array(),'users_index_index'));
			}
		}
		
		$this->view->form = $form;
	}
	
	/**
	 * 
	 * Смена пароля
	 */
	public function changepwdAction() {
		$auth = Zend_Auth::getInstance();
		
		
		$form_pwd = new Users_Form_Changepwd();
		
		if($this->_request->isPost() && $form_pwd->isValid($this->_request->getPost())) {
			$values = $this->_request->getPost();
			$user = Doctrine_Core::getTable('Users_Model_Users')->find($auth->getIdentity()->id);
			
			if($user->password == md5($values['old_password'])) {
				
				$user->password = md5($values['password']);
				$user->save();
				if(intval($values['send']) > 0) {
				//получаем настроки
			        $setting = Doctrine_Core::getTable('Default_Model_Setting')->find(1);
			        if($setting) {
			        	$template_msg = $setting->Translation['ru']->email_template_password;
			        	$template_msg = str_replace('%username%', $user->username, $template_msg);
			        	$template_msg = str_replace('%password%', $values['password'], $template_msg);
			        	
			        	$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
			        	$options = $bootstrap->getOptions();
			        	
			        	$template_msg = str_replace('%sitename%', $options['web']['sitename'], $template_msg);
			        	
			        	if($setting->is_smtp) {
			        		$smtp_config = array(
			        			'auth' => 'login',
			        			'username' => $setting->own_smtp_login,
			        			'password' => $setting->own_smtp_password,
			        		);
			        		$tr = new Zend_Mail_Transport_Smtp($setting->own_smtp_host, $smtp_config);
			        		Zend_Mail::setDefaultTransport($tr);
			        	}
			        	
			        	$mail = new Zend_Mail('KOI8-R');
			        	
			        	$mail->setBodyText(htmlspecialchars(iconv('utf-8', 'KOI8-R', $template_msg)));
						$mail->setFrom($setting->own_email, iconv('utf-8', 'KOI8-R',$setting->own_username));
						$mail->setSubject('=?koi8-r?B?'.base64_encode(convert_cyr_string(iconv('utf-8','cp1251',$this->view->translate('Новый пароль')), "w","k")).'?=');
						
						$mail->addTo($user->email);
						$mail->send();
			        }
				}
				$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Пароль успешно изменен!'));
				return $this->_redirect($this->view->url(array(),'users_index_index'));
			} else {
				$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Неверный пароль!'));
				return $this->_redirect($this->view->url(array(),'users_index_index'));
			}
				
		}
		
		$auth = Zend_Auth::getInstance();
		
		$user_id = $auth->getIdentity()->id;
		
		$user = Doctrine_Core::getTable('Users_Model_Users')->find($user_id);
		
		$populate = array(
			'username' => $user->username,
			'email' => $user->email,
			'show_email' => $user->Profile_Users_Alias->show_email,
			'show_birthday' => $user->Profile_Users_Alias->show_birthday,
			'show_me' => $user->Profile_Users_Alias->show_me,
			'birthday' => $user->Profile_Users_Alias->birthday,
			'about' => $user->Profile_Users_Alias->about,
			'sex' => $user->Profile_Users_Alias->sex
		);
		
		$form = new Users_Form_Profile();
		$form->setAction($this->view->url(array(),'users_index_profile'));
		
		$username = $form->getElement('username');
		$username->addValidator(new ZFEngine_Validate_Doctrine_NoRecordExist('Users_Model_Users','username', $user->username),true);
		$email = $form->getElement('email');
		$email->addValidator(new ZFEngine_Validate_Doctrine_NoRecordExist('Users_Model_Users','email', $user->email),true);
		
		$this->view->form = $form;
		$this->view->form_pwd = $form_pwd;
		
		
		$form->populate($populate);
		
		$this->renderScript('index/profile.phtml');
	}
	
	/**
	 * 
	 * Напоминание пароля
	 */
	public function passwordAction() {
		$form = new Users_Form_Password();
		$form->setAction($this->view->url(array(),'users_index_password'));
		
		if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
			$values = $form->getValues();
			
			//поиск пользователя
			$user = Doctrine_Core::getTable('Users_Model_Users')->findOneByEmail($values['email']);
			if($user) {
				//генерируем новый пароль
				$chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
		        // Определяем количество символов в $chars
		        $size = StrLen ( $chars ) - 1;
		        // Определяем пустую переменную, в которую и будем записывать символы.
		        $password = null;
		        // Создаём пароль.
		        $max = 8;
		        while ( $max -- )
		            $password .= $chars [rand ( 0, $size )];
		        $user->password = md5($password);
		        $user->save();
		        //получаем настроки
		        $setting = Doctrine_Core::getTable('Default_Model_Setting')->find(1);
		        if($setting) {
		        	$template_msg = $setting->Translation['ru']->email_template_password;
		        	$template_msg = str_replace('%username%', $user->username, $template_msg);
		        	$template_msg = str_replace('%password%', $password, $template_msg);
		        	
		        	$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
		        	$options = $bootstrap->getOptions();
		        	
		        	$template_msg = str_replace('%sitename%', $options['web']['sitename'], $template_msg);
		        	
		        	if($setting->is_smtp) {
		        		$smtp_config = array(
		        			'auth' => 'login',
		        			'username' => $setting->own_smtp_login,
		        			'password' => $setting->own_smtp_password,
		        		);
		        		$tr = new Zend_Mail_Transport_Smtp($setting->own_smtp_host, $smtp_config);
		        		Zend_Mail::setDefaultTransport($tr);
		        	}
		        	
		        	$mail = new Zend_Mail('KOI8-R');
		        	
		        	$mail->setBodyText(htmlspecialchars(iconv('utf-8', 'KOI8-R', $template_msg)));
					$mail->setFrom($setting->own_email, iconv('utf-8', 'KOI8-R',$setting->own_username));
					$mail->setSubject('=?koi8-r?B?'.base64_encode(convert_cyr_string(iconv('utf-8','cp1251',$this->view->translate('Напоминание пароля')), "w","k")).'?=');
					
					$mail->addTo($user->email);
					$mail->send();
		        } else {
		        	throw new Zend_Controller_Action_Exception('Not found settings email', 500);
		        }
		        
				$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Новый пароль был выслан вам на email.'));
				 
				return $this->_redirect($this->view->url(array(),'users_index_password'));
			} else {
				$this->_helper
				     ->getHelper('FlashMessenger')
					 ->addMessage($this->view->translate('Пользователь с таким email не был найден. Попробуйте зарегистрироваться.'));
				 
				return $this->_redirect($this->view->url(array(),'users_index_password'));
			}
		}
		
		$this->view->form = $form;
	}
	
	/**
	 * 
	 * Регистрация пользователя
	 */
	public function registerAction() {
		$auth = Zend_Auth::getInstance();
		
		$form = new Users_Form_Register();
		$form->setAction($this->view->url(array(),'users_index_register'));
		
		$userSession = new Zend_Session_Namespace('register');
		if(isset($userSession->userData)) {
			$form->removeElement('password');
			$form->removeElement('confirm');
			$form->removeElement('username');
			
			if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
				$values = $form->getValues();
				$user = new Users_Model_Users();
				
				$userData = $userSession->userData;
				
				$user->username = $userData['username'];
				$user->email = $values['email'];
				$user->password = md5($userData['password']);
				$user->is_openid = true;
                $user->identity = $userData['openid_identity'];
                $user->provider = $userData['provider'];
                $user->created_at = time();
                $user->last_ip = $this->_request->getClientIp();
                $user->save();
                
                
                $modelName = 'Users_Model_Users';
                $username = $userData['username'];
                $password = md5($userData['password']);
				$authAdapter = new ZendX_Doctrine_Auth_Adapter(
										Doctrine_Core::getConnectionByTableName($modelName),
										($modelName . ' u'),
										'u.username',
										'u.password',
										'u.is_delete = 0');
				$authAdapter->setIdentity($username)
	                        ->setCredential($password);
				
				$result = $auth->authenticate($authAdapter);
				unset($userSession->userData);
				if($result->isValid()) {
                	$storage = new Zend_Auth_Storage_Session();
					$storage->write($authAdapter->getResultRowObject());
					Zend_Session::rememberMe(60*60*24*14);
					$this->_helper->getHelper('FlashMessenger')
							->addMessage($this->view->translate('Вы успешно зарегистрировались!'));
					return $this->_redirect($this->view->url(array(), 'users_index_index'));
				} else {
					return $this->_redirect($this->view->url(array(), 'users_index_login'));
				}
			}
		} else {
			if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
				$values = $form->getValues();
				
				$user = new Users_Model_Users();
				
				$user->username = $values['username'];
				$user->password = md5($values['password']);
				$user->email = $values['email'];
				$user->created_at = time();
				$user->last_ip = $this->_request->getClientIp();
				$user->save();
				
				$modelName = 'Users_Model_Users';
                $username = $values['username'];
                $password = md5($values['password']);
				$authAdapter = new ZendX_Doctrine_Auth_Adapter(
										Doctrine_Core::getConnectionByTableName($modelName),
										($modelName . ' u'),
										'u.username',
										'u.password',
										'u.is_delete = 0');
				$authAdapter->setIdentity($username)
	                        ->setCredential($password);
				
				$result = $auth->authenticate($authAdapter);
				if($result->isValid()) {
                	$storage = new Zend_Auth_Storage_Session();
					$storage->write($authAdapter->getResultRowObject());
					Zend_Session::rememberMe(60*60*24*14);
					$this->_helper->getHelper('FlashMessenger')
							->addMessage($this->view->translate('Вы успешно зарегистрировались!'));
					return $this->_redirect($this->view->url(array(), 'users_index_index'));
				} else {
					return $this->_redirect($this->view->url(array(), 'users_index_login'));
				}
			}
		}
		
		$this->view->form = $form;
	}
	/**
	 * 
	 * Вход пользователя
	 * @throws Zend_Controller_Action_Exception
	 */
	public function loginAction() {
		$auth = Zend_Auth::getInstance();
		
		if(!$auth->hasIdentity()) {
			$form = new Default_Form_Login();
			$form->setMethod('post');
			$form->setAction($this->view->url(array(), 'users_index_login'));
			
			$modelName = 'Users_Model_Users';
			
			$is_openid = $this->_request->getParam('is_openid',0);
			
			if($is_openid == '0') {
				
				if($this->_request->isPost() && $form->isValid($this->_request->getPost())) {
					$username = $form->getValue('login');
					$password = $form->getValue('password');
					$remember = $form->getValue('remember');
					
					$authAdapter = new ZendX_Doctrine_Auth_Adapter(
										Doctrine_Core::getConnectionByTableName($modelName),
										($modelName . ' u'),
										'u.email = ? OR u.username',
										'u.password',
										'u.is_delete = 0');
					$authAdapter->setIdentity(array($username, $username))
		                        ->setCredential(md5($password));
					
					
					$result = $auth->authenticate($authAdapter);
					
					if ($result->isValid()) {
						$storage = new Zend_Auth_Storage_Session();
						$storage->write($authAdapter->getResultRowObject());
						//если нажата кнопка запомнить
						if(!intval($remember) > 0) {
							Zend_Session::rememberMe(60*60*24*14);
						}
						return $this->_redirect($this->view->url(array(), 'users_index_index'));
					} else {
						$this->_helper->getHelper('FlashMessenger')
							->addMessage($this->view->translate('Ошибка авторизации! ' . $result->getCode()));
						return $this->_redirect($this->view->url(array(), 'users_index_login'));
					}
				}
			} else {
				if($this->_request->isPost()) {
					$adapterParams = $this->_request->getPost();
					if(!key_exists('token', $adapterParams) OR !$adapterParams['token'])
						throw new Zend_Controller_Action_Exception('OpenId token not defined', 500);
					
					$loginza = new ZendExtra_OpenId_Broker_Loginza();
					$result = $loginza->authenticate($adapterParams);
					
					if($result->isValid()) {
						$username = $loginza->getProvider()->generateUsername();
						$userData = $loginza->getProvider()->generateUserData();
						$userData['provider'] = $loginza->getProvider()->getName();
						//Zend_Debug::dump($userData);
						
						//пробуем авторизовать
						$identity = $userData['openid_identity'];
						
						$authAdapter = new ZendX_Doctrine_Auth_Adapter(
										Doctrine_Core::getConnectionByTableName($modelName),
										($modelName . ' u'),
										'u.identity',
										'u.username',
										'u.is_delete = 0');
										
						$authAdapter->setIdentity($identity)
		                        ->setCredential($username);
		                $result = $auth->authenticate($authAdapter);
		                
		                if($result->isValid()) {
		                	$storage = new Zend_Auth_Storage_Session();
							$storage->write($authAdapter->getResultRowObject());
							Zend_Session::rememberMe(60*60*24*14);
							return $this->_redirect($this->view->url(array(), 'users_index_index'));
		                } else {
		                	if($userData['email']) {
			                	//пользователь не найден, регистрируем пользователя
			                	$user = new Users_Model_Users();
			                	
			                	$user->username = $username;
			                	$password = md5($userData['password']);
			                	$user->password = $password;
			                	$user->email = $userData['email'];
			                	//копируем аваторку
			                	$openIdData = $loginza->getUserData();
			                	if(key_exists('profile', $openIdData) && key_exists('photo', $openIdData['profile'])) {
			                		$avatarUrl = $openIdData['profile']['photo'];
			                		
			                	 	$im = @imagecreatefromjpeg($avatarUrl);//JPEG
			                	 	$ext = '.jpg';                                  
							        if ($im == false) {
							        	$im = @imagecreatefromgif($avatarUrl);//GIF
							        	$ext = '.gif';
							        }                
							        if ($im == false) {
							        	$im = @imagecreatefrompng($avatarUrl);//png
							        	$ext = '.png';
							        }                                      
							        if ($im != false) {
							        	$newName = $username . md5(time()) . $ext;
							            $path = APPLICATION_PATH . DS . '..' . DS . 'upload' . DS . 'media' . DS . 'avatars' . DS . 'original' . DS . $newName;
							            if(imagejpeg($im, $path)) {
							             	ImageDestroy($im);
							             	$user->localphoto = $newName;
							            }
							            ImageDestroy($im);
							        }
			                	}
			                	$user->is_openid = true;
			                	$user->identity = $identity;
			                	$user->provider = $loginza->getProvider()->getName();
			                	$user->created_at = time();
			                	$user->last_ip = $this->_request->getClientIp();
			                	$user->save();
			                	
			                	$authAdapter = new ZendX_Doctrine_Auth_Adapter(
										Doctrine_Core::getConnectionByTableName($modelName),
										($modelName . ' u'),
										'u.username',
										'u.password',
										'u.is_delete = 0');
								$authAdapter->setIdentity($username)
					                        ->setCredential($password);
								
								$result = $auth->authenticate($authAdapter);
								
								if($result->isValid()) {
				                	$storage = new Zend_Auth_Storage_Session();
									$storage->write($authAdapter->getResultRowObject());
									Zend_Session::rememberMe(60*60*24*14);
									$this->_helper->getHelper('FlashMessenger')
											->addMessage($this->view->translate('Вы успешно зарегистрировались!'));
									return $this->_redirect($this->view->url(array(), 'users_index_index'));
								} else {
									return $this->_redirect($this->view->url(array(), 'users_index_login'));
								}
		                	} else {
		                		//перенаправляем на страницу для заполнения email
		                		$userSession = new Zend_Session_Namespace('register');
		                		$userSession->userData = $userData;
		                		$this->_helper->getHelper('FlashMessenger')
											->addMessage($this->view->translate('Для продолжения регистрации, пожалуйста, укажите ваш Email'));
								return $this->_redirect($this->view->url(array(), 'users_index_register'));
		                	}
		                }
						
					} else {
						$this->_helper->getHelper('FlashMessenger')
							->addMessage($this->view->translate('Ошибка авторизации!'));
						return $this->_redirect($this->view->url(array(), 'users_index_login'));
						//Zend_Debug::dump($result->getMessages());
					}
				}
			}
			
			$this->view->form = $form;
		} else {
			return $this->_redirect($this->view->url(array(), 'users_index_index'));
		}
	}
	/**
	 * 
	 * Выход пользователя
	 */
	public function logoutAction() {
		$auth = Zend_Auth::getInstance();
		
		if($auth->hasIdentity()) {
			$auth->clearIdentity();
		}
		
		return $this->_redirect($this->view->url(array(), 'default_index_index'));
	}
	
}